#include <fstream>
#include <iostream>
#include <stdexcept>
#include <vector>
using namespace std;

struct Reading
{
    int hour;
    double temperatures;
};

int main(int argc, char **argv)
{
    if (argc < 3)
    {
        cout << "Usage: " << argv[0] << " input_file output_file\n";
        return 0;
    }
    try
    {
        string iname = argv[1];
        ifstream ifs(iname);
        if (!ifs)
        {
            throw runtime_error("can't open input file " + iname);
        }
        string oname = argv[2];
        ofstream ofs(oname);
        if (!ofs)
        {
            throw runtime_error("can't open output file " + iname);
        }
        vector<Reading> temps;
        int hour;
        double temperatures;
        while (ifs >> hour >> temperatures)
        {
            if (hour < 0 || hour > 23)
            {
                throw runtime_error("hour out of range");
            }
            temps.push_back({hour, temperatures});
        }
        for (const Reading &r : temps)
            ofs << '(' << r.hour << ',' << r.temperatures << ")\n";
        return 0;
    }
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
        return 1;
    }
}